added SSCLI 1.0
[windows-sources.git] / sdk / samples / all in on code / Visual Studio 2008 / VBSL3Text / MainPage.xaml.vb
blobfadc49fd0960e52e66c578e54be4fdb9962fde92
1 '****************************** Module Header ******************************'
2 ' Module Name: MainPage.xaml.vb
3 ' Project: VBSL3Text
4 ' Copyright (c) Microsoft Corporation.
5 '
6 ' This example demonstrates how to work with text in Silverlight using VB.
7 '
8 ' This source is subject to the Microsoft Public License.
9 ' See http://www.microsoft.com/opensource/licenses.mspx#Ms-PL.
10 ' All other rights reserved.
12 ' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
13 ' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
14 ' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
15 '***************************************************************************'
18 Partial Public Class MainPage
19 Inherits UserControl
21 Public Sub New()
22 InitializeComponent()
23 End Sub
25 Private Sub UserControl_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
26 Me.CreateSimpleTextBlock()
27 Me.CreateComplexTextBlock()
28 Me.FormatText()
29 End Sub
31 ''' <summary>
32 ''' This method creates a simple TextBlock, and adds it to the StackPanel
33 ''' simpleTBPlaceHolder.
34 ''' </summary>
35 ''' <remarks></remarks>
36 Private Sub CreateSimpleTextBlock()
37 Dim simpleTextBlock = New TextBlock()
38 simpleTextBlock.Text = "Simple TextBlock"
39 Me.simpleTBPlaceHolder.Children.Add(simpleTextBlock)
40 End Sub
42 ''' <summary>
43 ''' This method creates a TextBlock with multiple Runs and LineBreaks,
44 ''' and adds it to the StackPanel complexTBPlaceHolder.
45 ''' </summary>
46 ''' <remarks></remarks>
47 Private Sub CreateComplexTextBlock()
48 Dim complexTextBlock = New TextBlock()
49 Dim paragraph1 = New Run()
50 paragraph1.Text = "Paragraph1"
51 Dim lineBreak = New LineBreak()
52 Dim paragraph2 = New Run()
53 paragraph2.Text = "Paragraph2"
54 complexTextBlock.Inlines.Add(paragraph1)
55 complexTextBlock.Inlines.Add(lineBreak)
56 complexTextBlock.Inlines.Add(paragraph2)
57 Me.complexTBPlaceHolder.Children.Add(complexTextBlock)
58 End Sub
60 ''' <summary>
61 ''' This method creates a TextBlock with advanced format, and adds it to
62 ''' the StackPanel customizeFormatPlaceHolder.
63 ''' </summary>
64 ''' <remarks></remarks>
65 Private Sub FormatText()
66 Dim formatTextBlock = New TextBlock()
67 Dim paragraph1 = New Run()
68 paragraph1.Text = "Paragraph1"
69 paragraph1.FontFamily = New FontFamily("Magnetob.ttf#Magneto")
70 Dim lineBreak = New LineBreak()
71 Dim paragraph2 = New Run()
72 paragraph2.Text = "Paragraph2"
73 Dim brush = New LinearGradientBrush()
74 Dim stop1 = New GradientStop()
75 stop1.Color = Colors.Blue
76 stop1.Offset = 0D
77 brush.GradientStops.Add(stop1)
78 Dim stop2 = New GradientStop()
79 stop2.Color = Colors.Red
80 stop2.Offset = 1D
81 brush.GradientStops.Add(stop2)
82 paragraph2.Foreground = brush
83 formatTextBlock.Inlines.Add(paragraph1)
84 formatTextBlock.Inlines.Add(lineBreak)
85 formatTextBlock.Inlines.Add(paragraph2)
86 Me.customizeFormatPlaceHolder.Children.Add(formatTextBlock)
87 End Sub
89 ''' <summary>
90 ''' This method selects all text in the TextBox targetTextBox. Note you
91 ''' have to focus the TextBox so that the selection will be displayed.
92 ''' </summary>
93 ''' <param name="sender"></param>
94 ''' <param name="e"></param>
95 ''' <remarks></remarks>
96 Private Sub selectTextButton_Click(ByVal sender As Object, ByVal e As RoutedEventArgs)
97 Me.targetTextBox.SelectAll()
98 Me.targetTextBox.Focus()
99 End Sub
101 End Class